package neuroBot.gui;

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class DebugFileWriter {
	public static String fileName;
	public static DataOutputStream dos;

	public static void start() {
		GregorianCalendar cal = new GregorianCalendar();
		fileName = "debugFiles/" + cal.get(Calendar.DAY_OF_MONTH) + "-"
				+ (cal.get(Calendar.MONTH) + 1) + "-" + cal.get(Calendar.YEAR)
				+ " " + cal.get(Calendar.HOUR_OF_DAY) + "-"
				+ cal.get(Calendar.MINUTE) + "-" + cal.get(Calendar.SECOND)
				+ ".txt";
		new File(fileName.substring(0, fileName.lastIndexOf("/"))).mkdirs();
		try {
			dos = new DataOutputStream(new FileOutputStream(fileName, true));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	public static void print(String s) {
		try {
			dos.write(s.getBytes());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void println(String s) {
		try {
			s += "\n";
			dos.writeChars(s);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
